﻿using ASP;
using HKB.Common;
using HKB.Web;
using HKB.Web.Admin;
using System;
using System.Data;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.WebControls;
public partial class Admin_admin_ShowOrder : Admin, IRequiresSessionState
{
    public string orderID = "";
    public string ErrMsg = "";
    private Shop_Product _shop_product = null;
    private Shop_Order _shop_order = null;
    private Shop_DeliverType _shop_shop_delivertype = null;
    private SkinBll _skin = null;
    private Shop_OrderItem _shop_OrderItem = null;
    protected DefaultProfile profile
    {
        get
        {
            return (DefaultProfile)this.Context.Profile;
        }
    }
    protected global_asax applicationInstance
    {
        get
        {
            return (global_asax)this.Context.ApplicationInstance;
        }
    }
    protected Shop_Order shop_order
    {
        get
        {
            Shop_Order shop_order;
            if (this._shop_order == null)
            {
                this._shop_order = new Shop_Order(this.conn);
                shop_order = this._shop_order;
            }
            else
            {
                shop_order = this._shop_order;
            }
            return shop_order;
        }
    }
    protected Shop_Product shop_product
    {
        get
        {
            Shop_Product shop_product;
            if (this._shop_product == null)
            {
                this._shop_product = new Shop_Product(this.conn);
                shop_product = this._shop_product;
            }
            else
            {
                shop_product = this._shop_product;
            }
            return shop_product;
        }
    }
    protected Shop_DeliverType shop_shop_delivertype
    {
        get
        {
            Shop_DeliverType shop_shop_delivertype;
            if (this._shop_shop_delivertype == null)
            {
                this._shop_shop_delivertype = new Shop_DeliverType(this.conn);
                shop_shop_delivertype = this._shop_shop_delivertype;
            }
            else
            {
                shop_shop_delivertype = this._shop_shop_delivertype;
            }
            return shop_shop_delivertype;
        }
    }
    protected SkinBll m_skin
    {
        get
        {
            SkinBll skin;
            if (this._skin == null)
            {
                this._skin = new SkinBll(this.conn);
                skin = this._skin;
            }
            else
            {
                skin = this._skin;
            }
            return skin;
        }
    }
    protected Shop_OrderItem shop_OrderItem
    {
        get
        {
            Shop_OrderItem shop_OrderItem;
            if (this._shop_OrderItem == null)
            {
                this._shop_OrderItem = new Shop_OrderItem(this.conn);
                shop_OrderItem = this._shop_OrderItem;
            }
            else
            {
                shop_OrderItem = this._shop_OrderItem;
            }
            return shop_OrderItem;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!base.admin.CheckAdminPower(21))
        {
            base.WriteLog("View", Language.GetAdminMsg("Log/Access", "0"), "Order");
            base.WriteRightErrMsg();
        }
        this.orderID = Fetch.Get("orderID");
        this.loadPageInfo();
    }
    private void loadPageInfo()
    {
        DataTable orderByOrderFormNum = this.shop_order.GetOrderByOrderFormNum(this.orderID);
        if (orderByOrderFormNum != null && orderByOrderFormNum.Rows.Count > 0)
        {
            this.TxtOrderFormNum.Text = orderByOrderFormNum.Rows[0]["OrderFormNum"].ToString();
            this.BuyerLink.Text = orderByOrderFormNum.Rows[0]["BuyerName"].ToString();
            this.HyperLink2.Text = orderByOrderFormNum.Rows[0]["SalerName"].ToString();
            this.Order_InputTime.Text = orderByOrderFormNum.Rows[0]["InputTime"].ToString();
            if (orderByOrderFormNum.Rows[0]["NeedInvoice"].ToString() == "True")
            {
                this.CheckNeedInvoice.Checked = true;
            }
            else
            {
                this.CheckNeedInvoice.Checked = false;
            }
            if (orderByOrderFormNum.Rows[0]["Invoiced"].ToString() == "True")
            {
                this.CheckInvoied.Checked = true;
            }
            else
            {
                this.CheckInvoied.Checked = false;
            }
            string text = orderByOrderFormNum.Rows[0]["Status"].ToString();
            if (text != null)
            {
                if (!(text == "0"))
                {
                    if (!(text == "1"))
                    {
                        if (text == "2")
                        {
                            this.OrderStatus.Text = Language.GetMemberMsg("Order/OrderStatus2", new string[0]);
                        }
                    }
                    else
                    {
                        this.OrderStatus.Text = Language.GetMemberMsg("Order/OrderStatus1", new string[0]);
                    }
                }
                else
                {
                    this.OrderStatus.Text = Language.GetMemberMsg("Order/OrderStatus0", new string[0]);
                }
            }
            text = orderByOrderFormNum.Rows[0]["PayStatus"].ToString();
            if (text != null)
            {
                if (!(text == "0"))
                {
                    if (!(text == "1"))
                    {
                        if (text == "2")
                        {
                            this.PayStatus.Text = Language.GetMemberMsg("Order/PayStatus2", new string[0]);
                        }
                    }
                    else
                    {
                        this.PayStatus.Text = Language.GetMemberMsg("Order/PayStatus1", new string[0]);
                    }
                }
                else
                {
                    this.PayStatus.Text = Language.GetMemberMsg("Order/PayStatus0", new string[0]);
                }
            }
            text = orderByOrderFormNum.Rows[0]["DeliverStatus"].ToString();
            if (text != null)
            {
                if (!(text == "0"))
                {
                    if (!(text == "1"))
                    {
                        if (!(text == "2"))
                        {
                            if (text == "4")
                            {
                                this.DeliverStatus.Text = Language.GetMemberMsg("Order/DeliverStatus4", new string[0]);
                            }
                        }
                        else
                        {
                            this.DeliverStatus.Text = Language.GetMemberMsg("Order/DeliverStatus2", new string[0]);
                        }
                    }
                    else
                    {
                        this.DeliverStatus.Text = Language.GetMemberMsg("Order/DeliverStatus1", new string[0]);
                    }
                }
                else
                {
                    this.DeliverStatus.Text = Language.GetMemberMsg("Order/DeliverStatus0", new string[0]);
                }
            }
            this.Contacter_Name.Text = orderByOrderFormNum.Rows[0]["ContacterName"].ToString();
            this.Contacter_Address.Text = orderByOrderFormNum.Rows[0]["Address"].ToString();
            this.Contacter_Email.Text = orderByOrderFormNum.Rows[0]["Email"].ToString();
            if (orderByOrderFormNum.Rows[0]["NeedInvoice"].ToString() == "True")
            {
                this.Need_Invoiced.Text = orderByOrderFormNum.Rows[0]["InvoiceContent"].ToString();
            }
            else
            {
                this.Need_Invoiced.Text = "不需要发票";
            }
            this.Contacter_Phone.Text = orderByOrderFormNum.Rows[0]["Phone"].ToString();
            this.Contacter_ZipCode.Text = orderByOrderFormNum.Rows[0]["ZipCode"].ToString();
            this.Contacter_Mobile.Text = orderByOrderFormNum.Rows[0]["Mobile"].ToString();
            if (orderByOrderFormNum.Rows[0]["DeliverTypeName"].ToString() == string.Empty)
            {
                this.Deliver_ChargePaymentType.Text = "未选择";
            }
            else
            {
                this.Deliver_ChargePaymentType.Text = orderByOrderFormNum.Rows[0]["DeliverTypeName"].ToString();
            }
            this.Order_Remark.Text = orderByOrderFormNum.Rows[0]["Remark"].ToString();
            DataTable byOrderNum = this.shop_OrderItem.GetByOrderNum(orderByOrderFormNum.Rows[0]["OrderFormNum"].ToString());
            this.GridView1.DataSource = byOrderNum;
            this.GridView1.DataBind();
        }
        else
        {
            this.WriteErrMsg3("", "该订单无效", "Admin_FeeCount.aspx");
        }
    }
}
